package org.arithmetic.sort;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.IntStream;

public class BubSort {
    /**
     * 冒泡排序
     */
    public static void bubbleSort() {
        int[] array = {49, 38, 65, 97, 76, 13, 27, 49};

        int temp = 0;
        for (int i = 0; i < array.length - 1; i++) {
            for (int j = 0; j < array.length - i - 1; j++) {
                if (array[j] > array[j + 1]) {
                    temp = array[j];
                    array[j] = array[j + 1];
                    array[j + 1] = temp;
                }
            }
            System.out.println("第" + (i + 1) + "趟排序结果：");
        }

        System.out.println("冒泡排序结果为：");
        for (int n : array)
            System.out.print(n + "\t");
    }

    public static void main(String[] args) {
        bubbleSort();
    }
}
